//引用方法

 // $.MsgBox.Alert("标题", "内容！",function(){ callback });   //alert提示框
 // $.MsgBox.Confirm("标题", "内容！",function(){ callback });  //confirm提示框


//弹出 确认/提示 信息框
$.MsgBox = {
    Alert: function (title, msg, callback) {
      GenerateHtml("alert", title, msg);
      btnOk(callback); //alert只是弹出消息，因此没必要用到回调函数callback
      btnNo();
    },
    Confirm: function (title, msg, callback) {
      GenerateHtml("confirm", title, msg);
      btnOk(callback);
      btnNo();
    },
    Loading: function(title, msg){
      GenerateHtml("loading", title, msg);
    }
  }
//确定按钮事件
function btnOk(callback) {
    $("#mb_btn_ok").click(function () {

      if (typeof (callback) == 'function') {
        callback();
        $(".mb-box,.overlay").remove();
      }else{
        $(".mb-box,.overlay").remove();
      }
    });
  }

//取消按钮事件
function btnNo() {
    $("#mb_btn_no,#mb_close").click(function () {
      $(".mb-box,.overlay").remove();
    });
}
//生成Html
var GenerateHtml = function (type, title, msg) {
    var _html = "";

    if(type == 'loading'){
      _html += '<div class="mb-box"><div class="hd">' + title + '</div><div class="bd">';
    }
    else{
      _html += '<div class="mb-box"><div class="hd"><div id="mb_close" class="close flr"><img src="'+AJAX_URL+'/img/inc/icon/close.png" alt=""></div>' + title + '</div><div class="bd">';
    }
    _html += '<p class="msg">' + msg + '</p><p class="btn-box">';

    if (type == "alert") {
      _html += '<a href="javascript:;"  id="mb_btn_ok" class="btn ok jm_btn5">确认</a>';
    }
    if (type == "confirm") {
      _html += ' <a href="javascript:;" id="mb_btn_no" class="btn canc jm_btn5">取消</a>';
      _html += '<a href="javascript:;"  id="mb_btn_ok" class="btn ok jm_btn5">确认</a>';
    }
    _html += '</p></div></div>';
    _html += '<div class="overlay"></div>';

    $("body").append(_html); //_html添加到body
}

